/**
 * Equipment model
 */
package data.converter.model;

import java.io.IOException;
import java.io.Writer;
import java.util.LinkedHashMap;

import org.json.simple.JSONStreamAware;
import org.json.simple.JSONValue;

public class Equipment extends Product implements JSONStreamAware{
	
	private double pricePerUnit;
	
	public Equipment(){}
	
	public Equipment(Product product) {
		super.setName(product.getName());
		super.setProductCode(product.getProductCode());
		super.setType(product.getType());
	}

	public double getPricePerUnit() {
		return pricePerUnit;
	}

	public void setPricePerUnit(double pricePerUnit) {
		this.pricePerUnit = pricePerUnit;
	}
	
	public void writeJSONString(Writer out){
		LinkedHashMap obj = new LinkedHashMap();
		obj.put("pricePerUnit", pricePerUnit);
		obj.put("productCode", getProductCode());
		obj.put("name", getName());
		try {
			JSONValue.writeJSONString(obj, out);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
